package com.longge;

public class FinalPrices {

    public int[] finalPrices(int[] prices) {

        int[] ans = new int[prices.length];
        for (int i = 0; i < prices.length; i++) {
            int iPrice = prices[i];
            ans[i] = iPrice;
            for (int j = i+1; j < prices.length; j++) {
                int jPrice = prices[j];
                if (iPrice >= jPrice) {
                    ans[i] = iPrice - jPrice;
                    break;
                }
            }
        }
        return ans;
    }
}
